{include file="public/head" /}
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">物业管理系统</a>
        <a>
          <cite>账单管理</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row" >
        <form class="layui-form layui-col-md12 x-so"  method="get" action="{url(admin/Billcheck/billList)}">

        </form>
      </div>
      <xblock>
        <button class="layui-btn " onclick="x_admin_show('修改账单','{:url('billAdd')}',680,680)"><i class="layui-icon"></i>修改账单</button>
        <span class="x-right" style="line-height:40px"></span>
      </xblock>
      <table class="layui-table"  id="table">
        <thead>
          <tr>

            <th style="text-align: center; font-size: 16px;">小区名称</th>
            <th style="text-align: center; font-size: 16px;">房号</th>
            <th style="text-align: center; font-size: 16px;">业主姓名</th>
            <th style="text-align: center; font-size: 16px;">费用类型</th>
            <th style="text-align: center; font-size: 16px;">账期</th>
            <th style="text-align: center; font-size: 16px;">应收金额</th>
            <th style="text-align: center; font-size: 16px;">状态</th>
            <th style="text-align: center; font-size: 16px;">创建时间</th>
            <th style="text-align: center; font-size: 16px;width: 8%">审核时间</th>
            <th style="text-align: center; font-size: 16px;width: 8%">操作</th>
            </tr>
        </thead>
        <tbody>
          {foreach $list as $val}
          <tr>

            <td style="text-align: center;">{$val.community_id}</td>
            <td style="text-align: center;">{$val.address}</td>
            <td style="text-align: center;">{$val.owner_name}</td>
            <td style="text-align: center;">{$val.costtype}</td>
            <td style="text-align: center;">{$val.acct_period}</td>


            <td style="text-align: center;">
              {$val.bill_entry_amount}
            </td>
            <td style="text-align: center;">
              {if $val.check_status=="1"}审核成功
              {elseif $val.check_status=="2"}审核中
              {elseif $val.check_status=="3"}审核失败
              {/if}

            </td>
            <td style="text-align: center;">
              {$val.create_time|date="Y-m-d H:i:s",###}
            </td>
            <td style="text-align: center;">
              {if $val.check_status!="2"}{$val.check_time|date="Y-m-d H:i:s",###}{/if}
            </td>
            <td style="text-align: center;width:12%;padding:3px 5px">
              {if $val.check_status=="2"}
              <a title="" class="layui-btn"  href="javascript:;" style="width:60px;height:34px;padding:0 2px" onclick="checksuccess('{$val.id}')">
                通过
              </a>
              <a title="" style="width:60px;height:34px;padding:0 2px" class="layui-btn layui-btn-danger"  href="javascript:;" onclick="checkfail('{$val.id}')">
                失败
              </a>
              {/if}
            </td>


          </tr>
          {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
          {$render}
        </div>
      </div>

    </div>
    <script>

      function checksuccess(id){
          layer.confirm('是否确定审核通过', function(){
              layui.jquery.ajax({
                  type: 'post',
                  url: "{:url('checksuccess')}",
                  data: {
                      id:id
                  },
                  success: function(data){
                      if(data=='ok'){
                          layer.alert("审核成功", {icon: 6},function () {

                              window.location.reload();
                          });
                      }else{
                          layer.msg(data);
                      }
                  }
              });

          })

      }

      function checkfail(id){
          layer.confirm('是否确定审核失败', function(){
              layui.jquery.ajax({
                  type: 'post',
                  url: "{:url('checkfail')}",
                  data: {
                      id:id
                  },
                  success: function(data){
                      if(data=='ok'){
                          layer.alert("审核完成", {icon: 6},function () {

                              window.location.reload();
                          });
                      }else{
                          layer.msg(data);
                      }
                  }
              });

          })

      }
      

    </script>
    <!-- 多条件查询 -->
    <script>

      layui.use(['form'], function() {
          var form = layui.form
          $("#foundkeycommunity").blur(function(){
            var _this = $(this);
            var foundkeycommunity=_this.val();
            //layer.alert(foundkeycommunity);
            var url = "{:url('admin/Roominfo/fetchdata')}"
              $.post(url, {community_name: foundkeycommunity, type: 5}, function(data) {
                  //console.log(data);
                  $('#community_id').html("")
                  var option = "<option value=''>小区</option>"
                  $('#community_id').append(option)
                  for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i]["community_id"] + "'>" + data[i]["community_name"] + "</option>"
                  $('#community_id').append(option)
                  }
                  
                  form.render('select')
              })
          })
          form.on('select(community_id)', function(f){
              var url = "{:url('admin/Roominfo/fetchdata')}"
              $.post(url, {community_id: f.value, type: 1}, function(data) {
                console.log(data);
                  $('#group').html("")
                  var option = "<option value=''>组团</option>"
                  $('#group').append(option)
                  for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#group').append(option)
                  }
                  
                  form.render('select')
              })
              
              $('#community_id').data('community_id', f.value)
          })

          form.on('select(group)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community
              var url = "{:url('admin/Roominfo/fetchdata')}"
              $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
                  $('#building').html("")
                  var option = "<option value=''>楼栋</option>"
                  $('#building').append(option)
                  for (var i = 0; i < data.length; i++) {
                      option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                      $('#building').append(option)
                  }
                  $('#group').data('group', f.value)
                  form.render('select')
              })
          })
  
          form.on('select(building)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community

              var data_group = $('#group').data('group')
              var get_group = "<?php if (isset($group)) { echo $group;}?>"
              var group = typeof data_group === 'undefined' ? get_group : data_group

              var url = "{:url('admin/Roominfo/fetchdata')}"
              $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
              $('#unit').html("")
              var option = "<option value=''>单元</option>"
              $('#unit').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#unit').append(option)
              }
              $('#building').data('building', f.value)
              form.render('select')
              })
          })
  
          form.on('select(unit)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community

              var data_group = $('#group').data('group')
              var get_group = "<?php if (isset($group)) { echo $group;}?>"
              var group = typeof data_group === 'undefined' ? get_group : data_group

              var data_building = $('#building').data('building')
              var get_building = "<?php if (isset($building)) { echo $building;}?>"
              var building = typeof data_building === 'undefined' ? get_building : data_building
      
              var url = "{:url('admin/Roominfo/fetchdata')}"
              $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
              $('#room').html("")
              var option = "<option value=''>房间</option>"
              $('#room').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#room').append(option)
              }
              $('#unit').data('unit', f.value)
              form.render('select')
              })
          })
  
      })
  </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>